#!/bin/bash

# 判断是否有python环境，是否存在pip

ret0=$(whoami)
if [ "${ret0}" = "root" ];then
    apt-get install python3 -y
    apt-get install sshpass -y
    ret1=$(which sshpass)
    if [ "${ret1}" = "" ];then
        echo -e "\n   [INFO] please install sshpass before run.\n"
        exit
    fi
else
    ret1=$(which pip)
    if [ "${ret1}" != "" ];then 
        # 存在pip
        pip install paramiko --user
    else
        # apt-get install sshpass
        echo "[INFO] Please install pip before running run.sh "
        exit
    fi
fi

# 开始运行
python3 main.py

# 查看结果
if [ -f "out_userpasswd.txt" ];then
    cat out_userpasswd.txt
fi